home *** CD-ROM | disk | FTP | other *** search
/ Internet 53 / INTERNET53.iso / pc / software / windows / building / coldfusion studio evaluation / data1.cab / CFS_Wizards / CFML / Verity_VOpenFile.wml < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.5 KB  |  43 lines

  1. <!--- parameters --->
  2. <CFSET WorkingDirectory = "$${WorkingDirectory}">
  3.  
  4.  
  5. <!--- security check --->
  6. <CFIF Find( '..', URL.ServerFilePath )
  7.     or not FindNoCase( WorkingDirectory, URL.ServerFilePath )
  8.     >
  9.     Error: You are not allowed to access this file
  10.     <CFABORT>
  11. </CFIF>
  12.  
  13.  
  14. <!--- extract the file extension --->
  15. <CFSET SeparatorPos = Find( '.', Reverse(URL.ServerFilePath) )>
  16. <CFSET RevSolidusPos = Find( '\', Reverse(URL.ServerFilePath) )>
  17. <CFIF SeparatorPos is 0> <!--- separator not found --->
  18.     <CFSET FileExt = ''>
  19. <CFELSEIF SeparatorPos gt RevSolidusPos> <!--- last separator before backslash --->
  20.     <CFSET FileExt = ''>
  21. <CFELSE>
  22.     <CFSET FileExt = Right( URL.ServerFilePath, SeparatorPos - 1 )>
  23. </CFIF>
  24.  
  25.  
  26. <!--- find the proper MIME type --->
  27. <CFIF FileExt is ''>            <CFSET FileType = "unknown">
  28. <CFELSEIF FileExt is 'pdf'>        <CFSET FileType = "application/pdf">
  29. <CFELSEIF FileExt is 'aif'>        <CFSET FileType = "audio/aiff">
  30. <CFELSEIF FileExt is 'aiff'>    <CFSET FileType = "audio/aiff">
  31. <CFELSEIF FileExt is 'art'>        <CFSET FileType = "image/x-jg">
  32. <CFELSEIF FileExt is 'cil'>        <CFSET FileType = "application/vnd.ms-artgalry">
  33. <CFELSEIF FileExt is 'gif'>        <CFSET FileType = "image/gif">
  34. <CFELSEIF FileExt is 'htm'>        <CFSET FileType = "text/html">
  35. <CFELSEIF FileExt is 'html'>    <CFSET FileType = "text/html">
  36. <CFELSE>                        <CFSET FileType = "unknown">
  37. </CFIF>
  38.  
  39.  
  40. <!--- return requested file --->
  41. <CFCONTENT TYPE="#FileType#" 
  42.     FILE="#URL.ServerFilePath#"
  43. >